refactor(operator-trend): collapse tier-rollup summary renderers onto a parametrized base (T3-2 phase 6f)#88
Merged
Conversation
… a parametrized base (T3-2 phase 6f) Collapse the rebuild / restore / rerererestore reset-reentry summary renderers onto one `_tier_summary_base` + `_TierSummarySpec` + per-tier specs. The three were structural clones differing only in the status key they read, the per-tier status tokens, and reworded prose; the shared status-string render skeleton was triplicated, the same drift risk that produced the phase-5 floor/freshness fixes. Proven byte-identical two ways: an exhaustive branch differential (168 cases per tier, spanning every status branch, hotspot fallback, blocked-reason presence, and label / hotspot-label combination) and the composer golden contract (zero diff). Public signatures unchanged; the prose templates were extracted from the source AST, never hand-typed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Collapse the three reset-reentry tier-rollup summary renderers —
..._rebuild_summary,..._rebuild_reentry_restore_summary,..._rebuild_reentry_restore_rerererestore_summary— onto one_tier_summary_base+ a_TierSummarySpecNamedTuple + three per-tier specs.Each public function is now a thin wrapper with its exact original signature.
Why
The three were structural clones (AST-identical after literal-blanking),
differing only in:
The status-string render skeleton was triplicated — the same drift risk that
already produced two real bugs earlier in this campaign (the phase-5 floor and
freshness-flag fixes). A future status branch now lands once, not three times.
Proof of byte-identical behavior
every status branch, both hotspot fallbacks, blocked-reason present/absent,
and label / hotspot-label combinations:
real(input) == base(input, spec)for every case.
tests/test_composer_golden_contract.py,47 passed).
The prose templates (
{label}/{hotspot_label}str.formatstrings) wereextracted from the source AST, never hand-typed, so the contract text is exact.
Verification
uv run pytest -q→ 2539 passed, 2 skippeduv run mypy src/operator_trend_closure_forecast_reset_controls.py→ cleanuv run ruff check src/ tests/→ cleanNet
136 insertions / 138 deletions(near line-neutral by design — theserenderers are mostly prose; the win is eliminating the triplicated render
skeleton and its drift risk, consistent with the phase-6 collapses).